﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>

<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=7"/>
    <title>Left</title>
    @if (false)
    {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )
    <script>
        function nodeClick(s, e) {
            parent.boardtop.noneChooseYear();
            var names = e.node.name.split('|');
            if (names.length == 1) {
                var clientLeftTreeViewObj = ASPxClientTreeView.Cast(s);
                var expand = clientLeftTreeViewObj.GetSelectedNode().GetExpanded();
                clientLeftTreeViewObj.GetSelectedNode().SetExpanded(!expand);
            }
            else {
                if (names.length == 2) {
                    parent.$("#contentframe").attr("src", names[0]);

                }
                else {
                    if (names.length == 3) {
                        if (names[2] == "Y") {
                            window.open(names[0]);
                        }
                        else {
                            parent.$("#contentframe").attr("src", names[0]);
                        }

                    }
                }
            }
        }

        function SetNode() {
            var name = nodeName.GetText();
            if (name != "") {
                var node = LeftTreeView.GetNodeByName(name);
                node.parent.SetExpanded(true);
                LeftTreeView.SetSelectedNode(node);

                var names = node.name.split('|');

                if (names.length == 2) {
                    parent.$("#contentframe").attr("src", names[0]);

                }
                else {
                    if (names.length == 3) {
                        if (names[2] == "Y") {
                            window.open(names[0]);
                        }
                        else {
                            parent.$("#contentframe").attr("src", names[0]);
                        }

                    }
                }
            }
        }
    </script>
</head>
<body>
@Html.Partial("LoadPanelPartial")
   <div class="leftPanel">
        @Html.DevExpress().TreeView(settings =>
{
    settings.Name = "LeftTreeView";
    settings.ShowTreeLines = true;
    settings.AllowSelectNode = true;
    settings.NameField = "Id";
    settings.TextField = "Name";
    settings.ImageUrlField = "ImageUrl";
    settings.EnableAnimation = false;
    settings.ClientSideEvents.NodeClick = "function(s, e) { nodeClick(s,e) }";
    settings.ClientSideEvents.Init = "SetNode";
    settings.PreRender = (source, e) =>
    {
        ASPxTreeView treeView = (ASPxTreeView)source;
        //treeView.ExpandAll();
    };

}).Bind(Model).GetHtml()

@Html.DevExpress().Label(settings=>
    {
        settings.Name = "nodeName";
        settings.Text = ViewData["SelectNodeName"].ToString();
        settings.ClientVisible = false;
    }).GetHtml()
    </div>
</body>
</html>
